# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load("@com_google_googleapis_imports//:imports.bzl", "cc_proto_library")

package(
    default_visibility = ["//visibility:public"],
    licenses = ["notice"],
)

cc_library(
    name = "pins_control_device",
    testonly = 1,
    srcs = ["pins_control_device.cc"],
    hdrs = ["pins_control_device.h"],
    deps = [
        "//gutil/gutil:status",
        "//gutil/gutil:testing",
        "//lib/gnmi:gnmi_helper",
        "//lib/p4rt:p4rt_programming_context",
        "//lib/p4rt:packet_listener",
        "//lib/validator:validator_lib",
        "//p4_pdpi:ir",
        "//p4_pdpi:ir_cc_proto",
        "//p4_pdpi:p4_runtime_session",
        "//p4_pdpi:pd",
        "//p4_pdpi/packetlib:packetlib_cc_proto",
        "//sai_p4/instantiations/google:instantiations",
        "//sai_p4/instantiations/google:sai_p4info_cc",
        "//sai_p4/instantiations/google:sai_pd_cc_proto",
        "//tests/forwarding:util",
        "//tests/lib:switch_test_setup_helpers",
        "//thinkit:control_device",
        "//thinkit:packet_generation_finalizer",
        "//thinkit:switch",
        "@com_github_gnmi//proto/gnmi:gnmi_cc_grpc_proto",
        "@com_github_gnmi//proto/gnmi:gnmi_cc_proto",
        "@com_github_gnoi//diag:diag_cc_grpc_proto",
        "@com_github_gnoi//diag:diag_cc_proto",
        "@com_github_gnoi//system:system_cc_grpc_proto",
        "@com_github_gnoi//system:system_cc_proto",
        "@com_github_google_glog//:glog",
        "@com_github_grpc_grpc//:grpc++",
        "@com_github_p4lang_p4runtime//:p4info_cc_proto",
        "@com_github_p4lang_p4runtime//:p4runtime_cc_proto",
        "@com_google_absl//absl/container:flat_hash_map",
        "@com_google_absl//absl/container:flat_hash_set",
        "@com_google_absl//absl/memory",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/time",
        "@com_google_absl//absl/types:span",
    ],
)

cc_library(
    name = "basic_switch",
    hdrs = ["basic_switch.h"],
    deps = [
        "//p4_pdpi:p4_runtime_session",
        "//thinkit:switch",
        "@com_github_gnmi//proto/gnmi:gnmi_cc_grpc_proto",
        "@com_github_gnoi//cert:cert_cc_grpc_proto",
        "@com_github_gnoi//diag:diag_cc_grpc_proto",
        "@com_github_gnoi//factory_reset:factory_reset_cc_grpc_proto",
        "@com_github_gnoi//os:os_cc_grpc_proto",
        "@com_github_gnoi//system:system_cc_grpc_proto",
        "@com_github_grpc_grpc//:grpc++_public_hdrs",
        "@com_github_grpc_grpc//:grpc_security_base",
        "@com_github_p4lang_p4runtime//:p4runtime_cc_grpc",
        "@com_google_absl//absl/status:statusor",
    ],
)

cc_library(
    name = "alpine_switch",
    hdrs = ["alpine_switch.h"],
    deps = [
        ":basic_switch",
        "//p4_pdpi:p4_runtime_session",
        "@com_github_grpc_grpc//:grpc++",
        "@com_github_grpc_grpc//:grpc_security_base",
        "@com_github_p4lang_p4runtime//:p4runtime_cc_grpc",
        "@com_google_absl//absl/log",
        "@com_google_absl//absl/status:statusor",
    ],
)

cc_test(
    name = "basic_switch_test",
    srcs = ["basic_switch_test.cc"],
    deps = [
        ":basic_switch",
        "//gutil/gutil:status_matchers",
        "@com_github_gnmi//proto/gnmi:gnmi_cc_grpc_proto",
        "@com_github_gnoi//cert:cert_cc_grpc_proto",
        "@com_github_gnoi//diag:diag_cc_grpc_proto",
        "@com_github_gnoi//factory_reset:factory_reset_cc_grpc_proto",
        "@com_github_gnoi//os:os_cc_grpc_proto",
        "@com_github_gnoi//system:system_cc_grpc_proto",
        "@com_github_grpc_grpc//:grpc++_public_hdrs",
        "@com_github_p4lang_p4runtime//:p4runtime_cc_grpc",
        "@com_google_googletest//:gtest_main",
    ],
)

cc_library(
    name = "ixia_helper",
    testonly = 1,
    srcs = ["ixia_helper.cc"],
    hdrs = ["ixia_helper.h"],
    deps = [
        ":ixia_helper_cc_proto",
        "//gutil/gutil:collections",
        "//gutil/gutil:overload",
        "//gutil/gutil:proto",
        "//gutil/gutil:status",
        "//lib/gnmi:gnmi_helper",
        "//lib/utils:json_utils",
        "//p4_pdpi/netaddr:ipv4_address",
        "//p4_pdpi/netaddr:ipv6_address",
        "//p4_pdpi/netaddr:mac_address",
        "//thinkit:generic_testbed",
        "@com_github_gnmi//proto/gnmi:gnmi_cc_grpc_proto",
        "@com_github_google_glog//:glog",
        "@com_github_nlohmann_json//:nlohmann_json",
        "@com_google_absl//absl/container:flat_hash_map",
        "@com_google_absl//absl/random",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/strings:str_format",
        "@com_google_absl//absl/time",
        "@com_google_absl//absl/types:span",
        "@com_google_protobuf//:protobuf",
    ],
)

cc_test(
    name = "ixia_helper_test",
    srcs = ["ixia_helper_test.cc"],
    deps = [
        ":ixia_helper",
        ":ixia_helper_cc_proto",
        "//gutil/gutil:proto",
        "//gutil/gutil:proto_matchers",
        "//gutil/gutil:status_matchers",
        "//lib/utils:json_test_utils",
        "//lib/utils:json_utils",
        "//thinkit:generic_testbed",
        "//thinkit:mock_generic_testbed",
        "@com_github_nlohmann_json//:nlohmann_json",
        "@com_google_absl//absl/log:check",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings:string_view",
        "@com_google_googletest//:gtest_main",
    ],
)

proto_library(
    name = "ixia_helper_proto",
    srcs = ["ixia_helper.proto"],
    deps = ["@com_google_protobuf//:struct_proto"],
)

cc_proto_library(
    name = "ixia_helper_cc_proto",
    deps = [":ixia_helper_proto"],
)

cc_library(
    name = "lacp_ixia_helper",
    testonly = True,
    srcs = ["lacp_ixia_helper.cc"],
    hdrs = ["lacp_ixia_helper.h"],
    deps = [
        ":ixia_helper",
        "//gutil/gutil:overload",
        "//thinkit:generic_testbed",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
    ],
)

cc_test(
    name = "lacp_ixia_helper_test",
    srcs = ["lacp_ixia_helper_test.cc"],
    deps = [
        ":ixia_helper",
        ":lacp_ixia_helper",
        "//gutil/gutil:status_matchers",
        "//lib/utils:json_test_utils",
        "//thinkit:generic_testbed",
        "//thinkit:mock_generic_testbed",
        "@com_google_absl//absl/strings",
        "@com_google_googletest//:gtest_main",
    ],
)

cc_library(
    name = "ixia_protocol_helper",
    testonly = True,
    srcs = ["ixia_protocol_helper.cc"],
    hdrs = ["ixia_protocol_helper.h"],
    deps = [
        ":ixia_helper",
        "//thinkit:generic_testbed",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/types:span",
    ],
)

cc_test(
    name = "ixia_protocol_helper_test",
    srcs = ["ixia_protocol_helper_test.cc"],
    deps = [
        ":ixia_protocol_helper",
        "//gutil/gutil:status_matchers",
        "//lib/utils:json_test_utils",
        "//thinkit:generic_testbed",
        "//thinkit:mock_generic_testbed",
        "@com_google_googletest//:gtest_main",
    ],
)

